package com.github.limit.web;

import com.alibaba.fastjson.JSONObject;
import com.github.limit.annotation.MethodAccessLimit;
import com.github.limit.annotation.TokenAccessLimit;
import com.github.limit.entity.CurrentLimit;
import com.github.limit.handler.AbstractLimitHandler;
import com.github.limit.response.Response;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @author: wangdejun
 * @create: 2019-10-12 15:48
 **/
@RestController
@RequestMapping("limit")
@MethodAccessLimit(limit = 20, order = 20)
public class LimitDataController {

    @MethodAccessLimit(limit = 20, order = 20, timeUnit = TimeUnit.MINUTES)
    @TokenAccessLimit(limit = 10, order = 10, timeUnit = TimeUnit.MILLISECONDS)
    @RequestMapping(value = "list")
    public String limitDataList() {
        Response response =  Response.builder().code(200).message("访问成功").data(AbstractLimitHandler.limitDataList());
        return JSONObject.toJSONString(response);
    }
}

